package com.whli.jee.common.share.entity;

/**
 * <em>返回结果JavaBean</em>
 * Created by whli on 2018/1/18.
 */
public class ResponseBean{
    private String code;
    private String message;
    private Integer count;
    private Object data;

    public static ResponseBean success(String message){
        return success("0",message);
    }

    public static ResponseBean success(Object data){
        return success("0",data);
    }

    public static ResponseBean success(String code,String message){
        return success(code,message,null);
    }

    public static ResponseBean success(String code,Object data){
        return success(code,null,data);
    }

    public static ResponseBean success(String code,String message,Object data){
        return getInstance(code,message,data);
    }

    public static ResponseBean fail(String message){
        return success("-1",message);
    }

    public static ResponseBean fail(Object data){
        return success("-1",data);
    }

    public static ResponseBean fail(String code,String message){
        return fail(code,message,null);
    }

    public static ResponseBean fail(String code,Object data){
        return fail(code,null,data);
    }

    public static ResponseBean fail(String code,String message,Object data){
        return getInstance(code,message,data);
    }

    public static ResponseBean getInstance(String code,String message,Object data){
        return getInstance(code,message,null,data);
    }

    public static ResponseBean getInstance(String code,String message,Integer count,Object data){
        ResponseBean bean = new ResponseBean();
        bean.setCode(code);
        bean.setMessage(message);
        bean.setCount(count);
        bean.setData(data);
        return bean;
    }


    public ResponseBean() {
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Integer getCount() {
        return count;
    }

    public void setCount(Integer count) {
        this.count = count;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
